package com.itheima.edu.day25DataGramDemo;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

public class SendDemo {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket();
        Scanner sc = new Scanner(System.in);
        while(true){
            System.out.println("请输入数据（886结束）；");
            String data = sc.next();
            byte[] bytes = data.getBytes();
            DatagramPacket dp = new DatagramPacket(bytes,bytes.length, InetAddress.getByName("127.0.0.1"),10000);
            ds.send(dp);
            if("886".equals(data)){
                break;
            }
        }
        ds.close();
    }
}
